home *** CD-ROM | disk | FTP | other *** search
- include devices/timer.i
- include dos/datetime.i
- include dos/dos.i
- include exec/io.i
- include exec/exec_lib.i
- include graphics/graphics_lib.i
- include libraries/dos_lib.i
-
- lea dosname(pc),a1 ;Init devices and libs
- move.l #36,d0
- CALLEXEC OpenLibrary
- move.l #ERROR_INVALID_RESIDENT_LIBRARY,d3
- move.l d0,dosbase
- beq doserr
- move.b #-1,d0
- jsr _LVOAllocSignal(a6)
- move.b d0,signum
- move.l #ERROR_NO_FREE_STORE,d3
- beq sigerr
- jsr _LVOCreateMsgPort(a6)
- move.l #ERROR_NO_FREE_STORE,d3
- move.l d0,msgport
- beq mperror
- move.l d0,a0
- move.l #IOTV_SIZE,d0
- jsr _LVOCreateIORequest(a6)
- move.l d0,ioreq
- beq reqerr
- move.l d0,a1
- lea devname(pc),a0
- moveq.l #UNIT_VBLANK,d0
- clr.l d1
- jsr _LVOOpenDevice(a6)
- tst.l d0
- bne deverr
- move.l #argstr,d1 ;Parse arguments
- move.l #tmpname,d2
- clr.l d3
- move.l dosbase(pc),a6
- jsr _LVOReadArgs(a6)
- move.l d0,rdargs
- jsr _LVOIoErr(a6)
- move.l d0,d3
- tst.l rdargs
- beq argserr
- move.l #0,a1
- CALLEXEC FindTask
- move.l d0,sigtask
- move.l logname(pc),d1 ;Open (or create) logfile
- move.l #MODE_READWRITE,d2
- move.l dosbase(pc),a6
- jsr _LVOOpen(a6)
- move.l d0,logfile
- jsr _LVOIoErr(a6) ;Save error code for case of fault
- move.l d0,d3
- move.l logfile(pc),d1
- tst.l d1
- beq logerr
- move.l #volume1,d2 ;Get logfile device name
- move.l #33,d3
- jsr _LVONameFromFH(a6)
- lea volume1(pc),a0
- bsr finddn
- move.l logfile(pc),d1 ;Set current offset to the end of logfile
- clr.l d2
- move.l #OFFSET_END,d3
- jsr _LVOSeek(a6)
- move.l tmpname(pc),d1 ;Open (or create) timefile
- move.l #MODE_READWRITE,d2
- move.l dosbase(pc),a6
- jsr _LVOOpen(a6)
- move.l d0,tmpfile
- jsr _LVOIoErr(a6) ;Get error code
- move.l d0,d3
- move.l tmpfile(pc),d1
- tst.l d1 ;Fail it there was an error
- beq tmperr2
- move.l #volume2,d2 ;Get timefile device name
- move.l #33,d3
- jsr _LVONameFromFH(a6)
- lea volume2(pc),a0
- bsr finddn
- move.l tmpfile(pc),d1 ;Try to read datestamp from timefile
- move.l #days,d2
- move.l #12,d3
- jsr _LVORead(a6)
- tst.l d0 ;If failed, this file is just created,
- beq normal ;and there was no failure
- bsr putdate ;Otherwise store failure time
- move.l logfile(pc),d1 ;Store warning text
- move.l #warntxt,d2
- jsr _LVOFPuts(a6)
- normal move.l #days,d1 ;Take current date
- jsr _LVODateStamp(a6)
- bsr putdate ;Put current date into file
- move.l logfile(pc),d1 ;Print 'started' string to file
- move.l #starttx,d2
- jsr _LVOFPuts(a6)
- move.l tmpfile(pc),d1 ;Close timefile
- jsr _LVOClose(a6)
- move.l logfile(pc),d1
- jsr _LVOClose(a6)
- move.l 4.w,a1
- move.w #_LVOColdReboot,a0
- move.l #newcrb,d0
- move.l a1,a6
- jsr _LVOSetFunction(a6)
- move.l d0,oldcrb
- loop move.l #days,d1
- move.l dosbase(pc),a6
- jsr _LVODateStamp(a6)
- move.l tmpname(pc),d1
- move.l #MODE_NEWFILE,d2
- jsr _LVOOpen(a6)
- move.l d0,tmpfile
- beq tmperr
- move.l d0,d1
- move.l #days,d2
- move.l #12,d3
- jsr _LVOWrite(a6)
- move.l tmpfile(pc),d1
- jsr _LVOClose(a6)
- tmperr move.l ioreq(pc),a1
- move.w #TR_ADDREQUEST,IO_COMMAND(a1)
- move.l delay(pc),a0
- move.l (a0),IOTV_TIME+TV_SECS(a1)
- move.l #0,IOTV_TIME+TV_MICRO(a1)
- CALLEXEC SendIO
- move.l msgport(pc),a0
- move.b MP_SIGBIT(a0),d1
- move.l #SIGBREAKF_CTRL_C,d0
- bset.l d1,d0
- move.b signum(pc),d1
- bset.l d1,d0
- jsr _LVOWait(a6)
- btst.l #SIGBREAKB_CTRL_C,d0
- bne quit
- move.b signum(pc),d1
- btst.l d1,d0
- bne reboot
- move.l ioreq(pc),a1
- jsr _LVOWaitIO(a6)
- beq loop
- quit move.l a6,a1
- move.w #_LVOColdReboot,a0
- move.l oldcrb(pc),d0
- jsr _LVOSetFunction(a6)
- move.l ioreq(pc),a1
- jsr _LVOAbortIO(a6)
- move.l ioreq(pc),a1
- jsr _LVOWaitIO(a6)
- move.l #days,d1
- move.l dosbase(pc),a6
- jsr _LVODateStamp(a6)
- move.l logname(pc),d1
- move.l #MODE_READWRITE,d2
- move.l dosbase(pc),a6
- jsr _LVOOpen(a6)
- move.l d0,logfile
- beq logerr2
- move.l d0,d1
- clr.l d2
- move.l #OFFSET_END,d3
- jsr _LVOSeek(a6)
- bsr putdate
- move.l logfile(pc),d1
- move.l #quittxt,d2
- jsr _LVOFPuts(a6)
- move.l logfile(pc),d1
- jsr _LVOClose(a6)
- logerr2 move.l tmpname(pc),d1
- jsr _LVODeleteFile(a6)
- clr.l d3
- bra logerr
- tmperr2 move.l logfile(pc),d1
- jsr _LVOClose(a6)
- logerr move.l rdargs(pc),d1
- jsr _LVOFreeArgs(a6)
- argserr move.l ioreq(pc),a1
- CALLEXEC CloseDevice
- deverr move.l ioreq(pc),a0
- jsr _LVODeleteIORequest(a6)
- reqerr move.l msgport(pc),a0
- jsr _LVODeleteMsgPort(a6)
- mperror move.b signum(pc),d0
- jsr _LVOFreeSignal(a6)
- sigerr move.l d3,d1
- clr.l d2
- move.l dosbase(pc),a6
- jsr _LVOPrintFault(a6)
- move.l dosbase(pc),a1
- CALLEXEC CloseLibrary
- doserr move.l d3,d0
- rts
- reboot move.l #days,d1
- move.l dosbase(pc),a6
- jsr _LVODateStamp(a6)
- move.l logname(pc),d1
- move.l #MODE_READWRITE,d2
- move.l dosbase(pc),a6
- jsr _LVOOpen(a6)
- move.l d0,logfile
- beq logerr3
- move.l d0,d1
- clr.l d2
- move.l #OFFSET_END,d3
- jsr _LVOSeek(a6)
- bsr putdate
- move.l logfile(pc),d1
- move.l #rebtxt,d2
- jsr _LVOFPuts(a6)
- move.l logfile(pc),d1
- jsr _LVOClose(a6)
- logerr3 move.l tmpname(pc),d1
- jsr _LVODeleteFile(a6)
- move.l #volume1,d1
- jsr _LVOInhibit(a6)
- lea volume1(pc),a0
- lea volume2(pc),a1
- comp move.b (a0)+,d0
- move.b (a1)+,d1
- cmp.b d0,d1
- bne differ
- tst.b d0
- bne comp
- bra same
- differ move.l #volume2,d1
- jsr _LVOInhibit(a6)
- same tst.l fix39(pc)
- beq nofix39
- lea gfxname(pc),a1
- clr.l d0
- CALLEXEC OpenLibrary
- tst.l d0
- beq nofix39
- move.l d0,a6
- sub.l a1,a1
- jsr _LVOLoadView(a6)
- jsr _LVOWaitTOF(a6)
- jsr _LVOWaitTOF(a6)
- nofix39 move.l oldcrb(pc),a0
- move.l 4.w,a6
- jmp (a0)
- putdate move.l #days,d1
- jsr _LVODateToStr(a6)
- move.l logfile(pc),d1
- move.l #strday,d2
- jsr _LVOFPuts(a6)
- move.l logfile(pc),d1
- move.l #strdate,d2
- jsr _LVOFPuts(a6)
- move.l logfile(pc),d1
- move.l #strtime,d2
- jmp _LVOFPuts(a6)
- finddn move.b (a0)+,d0
- cmp.b #':',d0
- bne finddn
- clr.b (a0)
- rts
- newcrb move.l sigtask(pc),a1
- clr.l d0
- move.b signum(pc),d1
- bset.l d1,d0
- CALLEXEC Signal
- clr.l d0
- jmp _LVOWait(a6)
-
- dosbase dc.l 0
- msgport dc.l 0
- ioreq dc.l 0
- rdargs dc.l 0
- tmpname dc.l 0
- logname dc.l 0
- delay dc.l 0
- fix39 dc.l 0
- days dc.l 0
- minutes dc.l 0
- ticks dc.l 0
- dc.b FORMAT_DOS
- dc.b 0
- dc.l strday
- dc.l strdat2
- dc.l strtim2
- logfile dc.l 0
- tmpfile dc.l 0
- oldcrb dc.l 0
- sigtask dc.l 0
- signum dc.b 0
-
- dc.b 0,'$VER:PowerTools v1.4 (29.01.2002)'
- dc.b $0A,'by Pavel Fedin <sonic@sonic.misa.ac.ru>',0
- dosname dc.b 'dos.library',0
- gfxname dc.b 'graphics.library',0
- devname dc.b 'timer.device',0
- argstr dc.b 'TIMEFILE/A,LOGFILE/A,DELAY/N,FIX39/S',0
- starttx dc.b ' - system started.',$0A,0
- warntxt dc.b ' - system failure detected.',$0A,0
- quittxt dc.b ' - BREAK signal received, logger exited.',$0A,0
- rebtxt dc.b ' - system rebooting.',$0A,0
-
- strday dcb.b LEN_DATSTRING
- dc.b 0
- strdate dc.b ' '
- strdat2 dcb.b LEN_DATSTRING
- dc.b 0
- strtime dc.b ' '
- strtim2 dcb.b LEN_DATSTRING
- dc.b 0
- volume1 dcb.b 33
- dc.b 0
- volume2 dcb.b 33
- dc.b 0